#include "ExecuteQueue.h"

#include "EventNode.h"

#include <stdio.h>
#include <stdlib.h>

struct _ExecuteQueue
{
	EventNode  parent_instance;
	EventList *command;
	int	   sock;
};

static void
execute_queue_finalize(ExecuteQueue *self)
{
	event_node_finalize(EVENT_NODE(self));
	event_object_unref(self->command);
}

ExecuteQueue *
execute_queue_new(void)
{
	ExecuteQueue *object = MALLOC_NEW(ExecuteQueue);

	event_node_init(EVENT_NODE(object));
	event_object_set_finalize(object, FINALIZE(execute_queue_finalize));

	object->command = NULL;
	object->sock	= -1;

	return object;
}

EventList *
execute_queue_get_command(ExecuteQueue *self)
{
	return_val_if_fail(self != NULL, execute_queue_get_command, NULL);
	return self->command;
}

int
execute_queue_get_sock(ExecuteQueue *self)
{
	return_val_if_fail(self != NULL, execute_queue_get_task_id, 0);
	return self->sock;
}

void
execute_queue_set(ExecuteQueue *self, int sock, EventList *list_cmd)
{
	return_if_fail(self != NULL, execute_queue_set);
	self->sock    = sock;
	self->command = list_cmd;
}
